package com.bestcem.xm.ticket.grpc.client.enums.survey;

import lombok.Getter;
import lombok.ToString;

import javax.annotation.Nullable;

/**
 * 问卷题目类型枚举
 *
 * @author XiaoYunSong <ys.xiao@idiaoyan.com>
 * @version v1.0
 * @date 2021/11/25 20:29
 */
@Getter
@ToString
public enum CustomTypeEnum {
    /*
     * 单选题
     */
    SINGLE(0, "single", "单选题"),
    /*
     * 多选题
     */
    MULTIPLE(1, "multiple", "多选题"),
    /*
     * 级联题
     */
    CASCADER(2, "cascader", "级联题"),
    /*
     * 填空题
     */
    BLANK(3, "blank", "填空题"),
    /*
     * 多项填空题
     */
    MULTIPLE_BLANK(4, "multiple_blank", "多项填空题"),
    /*
     * 横向填空题
     */
    HORZ_BLANK(5, "horz_blank", "横向填空题"),
    /*
     * 打分题
     */
    STAR_SCORE(6, "star_score", "打分题"),
    /*
     * 打分题
     */
    STAR(7, "star", "打分题"),
    /*
     * 游标打分题
     */
    CURSOR_SCORE(8, "cursor_score", "游标打分题"),
    /*
     * 游标打分题
     */
    CURSOR(9, "cursor", "游标打分题"),
    /*
     * NPS题
     */
    NPS(10, "nps", "NPS题"),
    /*
     * 排序题
     */
    SORT(11, "sort", "排序题"),
    /*
     * 比重题
     */
    PROPORTION(12, "proportion", "比重题"),
    /*
     * 矩阵单选题
     */
    MATRIX_SINGLE(13, "matrix_single", "矩阵单选题"),
    /*
     * 矩阵多选题
     */
    MATRIX_MULTIPLE(14, "matrix_multiple", "矩阵多选题"),
    /*
     * 矩阵填空题
     */
    MATRIX_BLANK(15, "matrix_blank", "矩阵填空题"),
    /*
     * 矩阵打分题
     */
    MATRIX_SCORE(16, "matrix_score", "矩阵打分题"),
    /*
     * 姓名题
     */
    INFO_USERNAME(17, "info_username", "姓名题"),
    /*
     * 邮箱题
     */
    INFO_EMAIL(18, "info_email", "邮箱题"),
    /*
     * 性别题
     */
    INFO_SEX(19, "info_sex", "性别题"),
    /*
     * 手机题
     */
    INFO_PHONE(20, "info_phone", "手机题"),
    /*
     * 时间题
     */
    INFO_TIME(21, "info_time", "时间题"),
    /*
     * 年龄题
     */
    INFO_AGE(22, "info_age", "年龄题"),
    /*
     * 学历题
     */
    INFO_EDUCATION(23, "info_education", "学历题"),
    /*
     * 职业题
     */
    INFO_OCCUPATION(24, "info_occupation", "职业题"),
    /*
     * 行业题
     */
    INFO_INDUSTRY(25, "info_industry", "行业题"),
    /*
     * 日期题
     */
    INFO_DATE(26, "info_date", "日期题"),
    /*
     * 地理位置题
     */
    INFO_GEOGRAPHY(27, "info_geography", "地理位置题"),
    /*
     * 城市地址题
     */
    CITY(28, "city", "城市地址题"),
    /*
     * 备注说明
     */
    DESCRIPTOR(29, "descriptor", "备注说明"),
    /*
     * 分页
     */
    PAGE(30, "page", "分页"),
    /*
     * 评价题
     */
    EVALUATION(31, "evaluation", "评价题"),
    /*
     * 分类题
     */
    CLASSIFY(32, "classify", "分类题"),
    /*
     * 图片选择题
     */
    IMAGE_SELECT(33, "image_select", "图片选择题"),
    /*
     * 自增表格题
     */
    AUTO_TABLE(34, "auto_table", "自增表格题");

    private final Integer index;

    private final String name;

    private final String info;

    CustomTypeEnum(Integer index, String name, String info) {
        this.name = name;
        this.index = index;
        this.info = info;
    }


    /**
     * 根据 name 获取枚举实体
     * 找不到则返回 null
     *
     * @param name 枚举name
     * @author XiaoYunSong <ys.xiao@idiaoyan.com>
     * @date 2021/11/25 21:11
     */
    @Nullable
    public static CustomTypeEnum getByName(String name) {
        for (CustomTypeEnum value : values()) {
            if (value.getName().equals(name)) {
                return value;
            }
        }
        return null;
    }
}
